import { request } from '../../../services/request';
import { SrnSignQueryParams, SrnSignResponse } from './types';

export const querySrnSign = async (params: SrnSignQueryParams): Promise<SrnSignResponse> => {
    console.log('请求参数:', params);

    try {
        const response = await request('/app/wms/srn/send/queryLog', {
            method: 'POST',
            body: JSON.stringify(params),
        });

        console.log('接口返回:', response);
        return response;
    } catch (error) {
        console.error('查询签收失败:', error);
        throw error;
    }
};

export const confirmSrnSign = async (params: { id: string; sign_quantity: number }): Promise<any> => {
    console.log('确认签收请求参数:', params);

    try {
        const response = await request('/app/wms/srn/send/sign', {
            method: 'POST',
            body: JSON.stringify(params),
        });

        console.log('确认签收接口返回:', response);
        return response;
    } catch (error) {
        console.error('确认签收失败:', error);
        throw error;
    }
};

export const getBodyListByBusNum = async (bus_num: string): Promise<any> => {
    try {
        const response = await request('/app/wms/asn/getBodyListByBusNum', {
            method: 'POST',
            body: JSON.stringify({ bus_num }),
        });
        return response;
    } catch (error) {
        console.error('获取产品列表失败:', error);
        throw error;
    }
};

export const getProductSkuList = async (product_id: string): Promise<any> => {
    try {
        const response = await request('/app/appProduct/getProductSkuList', {
            method: 'POST',
            body: JSON.stringify({ product_id }),
        });
        return response;
    } catch (error) {
        console.error('获取SKU列表失败:', error);
        throw error;
    }
};
